#! /bin/mksh

. $(realpath "$0" | xargs dirname)/../menu/dmenuconf

WINEAPPSDIR="$HOME/bin/apps/wine"

OPT_VANILLA="WINEPREFIX=$HOME/.wine_vanilla"
OPT_JAP="LANG=ja_JP.UTF-8"
# WINE_CALL="wine start /unix"
WINE_CALL="wine"

DLIST="\
anydesk
irfan
winecfg
foobar-x64
telegram
winrar
magnify
"

WLIST="\
default
default-jap
vanilla
vanilla-jap
"

WINE_CMD=""
WineDmenu="$(echo -e "$WLIST" | dmenu -i -b -p WINELAUNCHOPTS  -nb "$DMENUBG" -nf "$DMENUFG" -sb "$DMENUFG" -sf "$DMENUBG" -fn "$DMENUFONT")"
case "$WineDmenu"
{
	"default")     WINE_CMD="$WINE_CALL" ;;
	"default-jap") WINE_CMD="env $OPT_JAP $WINE_CALL" ;;
	"vanilla")     WINE_CMD="env $OPT_VANILLA $WINE_CALL" ;;
	"vanilla-jap") WINE_CMD="env $OPT_JAP $OPT_VANILLA $WINE_CALL" ;;
}

AAA="$(echo -e "$DLIST" | dmenu -i -b -p RunIn:$WineDmenu -nb "$DMENUBG" -nf "$DMENUFG" -sb "$DMENUFG" -sf "$DMENUBG" -fn "$DMENUFONT")"

cd $WINEAPPSDIR

case "$AAA"
{
	"irfan")      cd ./IrfanView && $WINE_CMD ./i_view32.exe & ;;
	"anydesk")    cd ./anydesk && $WINE_CMD ./AnyDesk.exe & ;;
	"winecfg")    $WINE_CMD winecfg & ;;
	"telegram")   cd ./Telegram && $WINE_CMD ./Telegram.exe & ;;
	"winrar")     cd ./WinRAR && $WINE_CMD ./WinRAR.exe & ;;
	"magnify")    cd "./Magnifixer" && $WINE_CMD ./Magnifixer.exe & ;;
	"foobar-x64") cd ./foobar2000x64 && $WINE_CMD ./foobar2000.exe & ;;
}

exit 0
